
namespace JufGame.CptMod
{
	/// <summary>
	/// 持续时间：玩家在该角色上投入的时间以及注意力
	/// </summary>
	public class Duration
	{
		public float DurtVaule { get; private set; } = 0;
		private float lastTime;
		public Duration()
		{
			lastTime = 0;
		}
		/// <summary>
		/// 计算持续时间，由所注意到的可观察度在时间上的积分求得
		/// </summary>
		/// <param name="observability">可观察度</param>
		/// <param name="attention">注意力</param>
		/// <param name="deltaTime">时间间隔</param>
		public void CalculateDuration(float observability, float attention, float deltaTime)
		{
			if (observability == 0 && DurtVaule > 0)
			{
				DurtVaule -= deltaTime * deltaTime;
			}
			else
			{
				DurtVaule = lastTime + observability * attention * deltaTime;
				lastTime = DurtVaule;
			}
		}
	}
}
